Learn how to add banners to your results using Rules.
Hits
widget or InfiniteHits
widget from one of the following: InstantSearch.js version 4.73.0 or later, React InstantSearch version 7.12.0 or later, or Vue InstantSearch version 4.19.0 or later.harry potter
and click Apply.
saveRule
method.
When adding a rule, you need to define a condition and a consequence.
In the consequence, add search parameters and configure renderingContent
using the following template:
renderingContent.widgets.banners
property is present in the API response.
You can use the Hits
or InfiniteHits
widgets from InstantSearch.js, React InstantSearch, or Vue InstantSearch to display the banner.
The banner renders automatically unless you have configured the widget to hide it.
saveRule
method. When setting a rule, you need to define a condition and a consequence.
For the preceding example, you want to show the banner whenever the query contains “harry potter”. You don’t need it to be exact.
If the query is “harry potter azkaban” or “books harry potter”, you still want to display the promotion.
{ "promo_content": "20% OFF on all Harry Potter books!" }
userData
property is present in the API response. For example, with InstantSearch:
queryRuleCustomData
for InstantSearch.js<QueryRulesCustomData>
for React InstantSearchais-query-rule-custom-data
for Vue InstantSearchqueryRuleContext
for InstantSearch.js<QueryRuleContext>
for React InstantSearchais-query-rule-context
for Vue InstantSearchobjectID
, which in this case just happens to be for the Huawei Honor Note 10.
Don’t assume that a rule that was created some time ago will have a smaller objectID
than a more recent rule. It’s best to not rely on objectID
to determine precedence but to manually set it.